<template>
  <div class="signin-signup">
    <div class="text">修改密码</div>
    <EditPass @onSubmitPass="onSubmitPass" />
  </div>
  <div class="change-password container">
    <!-- form表单容器 -->
    <div class="forms-container"></div>
    <!-- 左右切换动画 -->
    <div class="panels-container">
      <div class="panel left-panel">
        <div class="content"></div>
        <img src="@/assets/img/log.svg" class="image" alt="" />
      </div>

      <div class="panel right-panel">
        <div class="content"></div>
        <img src="@/assets/img/register.svg" class="image" alt="" />
      </div>
    </div>
  </div>
</template>
<script>
import {
  ref,
  reactive,
  toRefs,
  computed,
  watch,
  getCurrentInstance,
  onMounted, //组件安装完成的钩子
  onUpdated, //组件数据更新时的钩子
  onUnmounted,
} from "vue";
// 引入router
import { useRouter } from "vue-router";
import { useStore } from "vuex";

import { logout } from "@/api/login";
import EditPass from "@/views/Login/components/EditPass";

function useFeatureX() {
  // 响应式数据抽离出setup 具有代码可读性
  const state = reactive({});
  return state;
}

export default {
  name: "changePassword",
  components: { EditPass },

  setup() {
    const { ctx } = getCurrentInstance();

    // 响应式数据抽离
    const data = useFeatureX();
    const store = useStore();
    const onSubmitPass = (datas) => {
      let { password, password2 } = datas;
      let params = {
        oldPassword: password,
        password: password2,
      };
      store.dispatch("login/editPassword", params);
    };
    return { onSubmitPass };
  },
};
</script>


<style lang="scss" scoped>
.container {
  position: relative;
  width: 100%;
  background-color: #fff;
  min-height: 100vh;
  overflow: hidden;
  z-index: -1;
}

.forms-container {
  position: absolute;
  width: 100%;
  height: 100%;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.8);
  top: 0;
  left: 0;
  z-index: 99;
  // transform: translate(-50%, -50%);
}

.signin-signup {
  position: absolute;
  top: 35%;
  left: 50%;
  width: 44%;
  transform: translate(-50%, -50%);
  transition: 1s 0.7s ease-in-out;
  display: grid;
  grid-template-columns: 1fr;
  z-index: 999;
  background-color: rgba(255, 255, 255, 0.3);
  min-height: 400px;
  border-radius: 50px 10px 50px 10px;
  text-align: center;
  padding: 40px 30px;
  box-sizing: border-box;
  .text {
    position: absolute;
    width: 20px;
    top: 50px;
    left: 20px;
    font-size: 28px;
    line-height: 34px;
    word-wrap: break-word;
    letter-spacing: 300px;
    word-break: break-all;
    color: rgba(255, 255, 255, 0.8);
  }
}

/* 左右切换动画 */
.social-text {
  padding: 0.7rem 0;
  font-size: 1rem;
}

.social-media {
  display: flex;
  justify-content: center;
}

.social-icon {
  height: 46px;
  width: 46px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0.45rem;
  color: #333;
  border-radius: 50%;
  border: 1px solid #333;
  text-decoration: none;
  font-size: 1.1rem;
  transition: 0.3s;
}

.social-icon:hover {
  color: #4481eb;
  border-color: #4481eb;
}

.btn {
  width: 150px;
  background-color: #5995fd;
  border: none;
  outline: none;
  height: 49px;
  border-radius: 49px;
  color: #fff;
  text-transform: uppercase;
  font-weight: 600;
  margin: 10px 0;
  cursor: pointer;
  transition: 0.5s;
}

.btn:hover {
  background-color: #4d84e2;
}
.panels-container {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.container:before {
  content: "";
  position: absolute;
  height: 150vh;
  width: 100%;
  top: -50%;
  right: 0;
  transform: translateY(-15%);
  background-image: linear-gradient(-45deg, #4481eb 0%, #04befe 100%);
  transition: 1.8s ease-in-out;
  border-radius: 50%;
  // z-index: 6;
}

.image {
  width: 100%;
  transition: transform 1.1s ease-in-out;
  transition-delay: 0.4s;
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-around;
  text-align: center;
  z-index: 6;
}

.left-panel {
  pointer-events: all;
  padding: 3rem 17% 2rem 12%;
}

.right-panel {
  pointer-events: none;
  padding: 3rem 12% 2rem 17%;
}

.panel .content {
  color: #fff;
  transition: transform 0.9s ease-in-out;
  transition-delay: 0.6s;
}

.panel h1 {
  font-weight: 600;
  line-height: 1;
  font-size: 1.5rem;
}

.panel p {
  font-size: 0.95rem;
  padding: 0.7rem 0;
}

.btn.transparent {
  margin: 0;
  background: none;
  border: 2px solid #fff;
  width: 130px;
  height: 41px;
  font-weight: 600;
  font-size: 0.8rem;
}

.right-panel .image,
.right-panel .content {
  width: 80%;
  // transform: translateX(800px);
}

/* ANIMATION */

.container.sign-up-mode:before {
  transform: translate(100%, -50%);
  right: 52%;
}

.container .left-panel .image,
.container.sign-up-mode .left-panel .content {
  transform: translateX(-200px);
  width: 80%;
}

.container.sign-up-mode .signin-signup {
  left: 25%;
}

.container.sign-up-mode form.sign-up-form {
  opacity: 1;
  z-index: 2;
}

.container.sign-up-mode form.sign-in-form {
  opacity: 0;
  z-index: 1;
}

.container.sign-up-mode .right-panel .image,
.container.sign-up-mode .right-panel .content {
  transform: translateX(0%);
}

.container.sign-up-mode .left-panel {
  pointer-events: none;
}

.container.sign-up-mode .right-panel {
  pointer-events: all;
}

/* 控制login & register显示 */
form {
  padding: 0rem 5rem;
  transition: all 0.2s 0.7s;
  overflow: hidden;
}

form.sign-in-form {
  z-index: 2;
}

form.registerForm {
  opacity: 0;
  z-index: 1;
}

/* register */
.registerForm {
  position: absolute;
  width: 100%;
  // background-color: #fff;
  // padding: 40px 20px 20px 20px;
  // border-radius: 5px;
  // box-shadow: 0px 5px 10px #cccc;
}

.submit_btn {
  width: 100%;
}
</style>
<style  lang="scss">
input.el-input__inner,
.el-input-group__append,
.el-input-group__prepend,
.el-button {
  background-color: rgba(255, 255, 255, 0.5) !important;
}
.el-form-item {
  margin-bottom: 35px;
}
.el-input.is-disabled .el-input__inner {
  color: #606266;
}
</style>